package com.mdb.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtil {
	private static final Properties props = new Properties();

	@SuppressWarnings("resource")
	public static void loadConfig(String url) throws Exception {
		InputStream stream = null;
		File file = new File(url);
		if (file.exists()) {
			stream = new FileInputStream(url);
		} else {
			stream = PropertiesUtil.class.getClassLoader().getResourceAsStream(url);
		}
		try {
			props.load(stream);
		} finally {
			stream.close();
		}
	}

	public static String getString(String key) {

		return props.getProperty(key);
	}

	public static int getInt(String key) {

		return Integer.parseInt(getString(key));
	}

	public static boolean getBoolean(String key) {

		return Boolean.parseBoolean(getString(key));
	}
}
